package com.mz.ozy.mvp.presenter;

import android.app.Activity;
import android.content.Context;

import com.mz.ozy.base.BasePresenterImpl;
import com.mz.ozy.bean.ShogBean;
import com.mz.ozy.bean.ShogDetailBean;
import com.mz.ozy.mvp.model.IdyllicPastureModel;
import com.mz.ozy.mvp.model.OrganicModel;
import com.mz.ozy.mvp.view.IdyllicPastureContract;
import com.mz.ozy.mvp.view.OrganicContract;
import com.mz.ozy.net.MyObserver;
import com.mz.ozy.utils.RxUtil;

import okhttp3.ResponseBody;

/**
 * @author lifeStyle on 2020/4/26 0026.
 */
public class OrganicPresenter extends BasePresenterImpl<OrganicContract.View> implements OrganicContract.Presenter {
    private OrganicModel shogModel;

    public OrganicPresenter() {
        super();
        shogModel = new OrganicModel();
    }


    @Override
    public void getInfo(Activity activity, String page) {
        shogModel.getInfo(activity, page).
                compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<ShogBean>(mView, false) {
                    @Override
                    public void onSuccesss(ShogBean homeMerBean) {
                        mView.getInfo(homeMerBean);

                    }
                });
    }

    @Override
    public void getInfoDetailSuccess(Context context, String irst) {
        shogModel.getInfoDetail(context, irst).
                compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<ShogDetailBean>(mView, false) {
                    @Override
                    public void onSuccesss(ShogDetailBean homeMerBean) {
                        mView.getInfoDetailSuccess(homeMerBean);

                    }
                });
    }
}
